package lights;

import hulppakket.Color3f;
import hulppakket.Intersection;
import hulppakket.Point3f;
import hulppakket.Vector3f;

public class PointLight extends Light {

	private Point3f position;
	private Vector3f a, b;

	public PointLight(Point3f position, float intensity, Color3f color,
			String name) {
		super(color, intensity, name);
		this.position = position;
		a = new Vector3f(1f, 0, 0);
		b = new Vector3f(0, 0, 1f);
	}

	private Point3f getPosition() {
		float fa = (float) Math.random();
		float fb = (float) Math.random();
		Vector3f correction = new Vector3f();
		correction = correction.add(this.a.scale(fa)).add(this.b.scale(fb));;
		return this.position.add(correction);
	}

	@Override
	public Vector3f getVectorPointingToLight(Intersection intersection) {
		Vector3f result = new Vector3f(this.getPosition());
		result = result.substract(intersection.getHitpoint());
		result = result.normalize();
		return result;
	}
}
